
package loader.sandbox;

import java.net.URL;

import javax.jnlp.UnavailableServiceException;

/**
 * See <a href="">javax / jnlp / ServiceManager</a>
 */
public final class ServiceManager
    extends Object
    implements javax.jnlp.ServiceManagerStub
{
    static void Create(){
        javax.jnlp.ServiceManager.setServiceManagerStub(new ServiceManager());
    }

    private final static String[] Names = {
        BasicService.Name,
        PersistenceService.Name,
        ContentHandlers.Name,
    };
    private final java.util.Map<String,Object> services = new java.util.HashMap<String,Object>();



    public ServiceManager(){
        super();
        services.put(BasicService.Name,new BasicService());
        services.put(PersistenceService.Name,new PersistenceService());
        services.put(ContentHandlers.Name,new ContentHandlers());
    }


    public PersistenceService getPersistenceService(){
        return (PersistenceService)this.services.get(PersistenceService.Name);
    }
    public BasicService getBasicService(){
        return (BasicService)this.services.get(BasicService.Name);
    }
    public ContentHandlers getContentHandlers(){
        return (ContentHandlers)this.services.get(ContentHandlers.Name);
    }

    public Object lookup(String name)
        throws UnavailableServiceException
    {
        Object service = this.services.get(name);
        if (null == service)
            throw new UnavailableServiceException(name);
        else
            return service;
    }
    public String[] getServiceNames(){
        return Names.clone();
    }
}
